const url = 'http://domain.com/?user=anonymous&city=chengdu#xx'//考虑hash
const parseUrl = function(url){
    let querys = url.split('&')
    querys[0] = querys[0].split("?").pop()//去掉域名
    querys[querys.length-1] =querys[querys.length-1].split("#").shift()
    let res = {}
    querys.forEach(query=>{
        let key = query.split("=")[0]
        let val = query.split("=")[1]
        res[key] = val
    })
    return res;
}

console.log(parseUrl(url))